package JavaSEAdvance.day07_Exception;

import java.util.Arrays;

/**
 * @author Xiao
 * @date 2021/7/24
 */
public class D701_ThrowDemo01 {
    public static void main(String[] args) {
        int[] arr = {1, 3, 5};
        int[] arr1 = null;

        try {
            printArr(arr1);
        } catch (NullPointerException e) {
            e.getMessage();
            System.out.println("您传入的数组为null");
        }
        printArr(arr);
    }

    private static void printArr(int[] arr) {
        if (arr == null) {
            throw new NullPointerException();
        } else {
            System.out.println(Arrays.toString(arr));
        }
    }
}
